<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>openresty demo</title>
    <style>
      body {
        position: relative;
      }
      .right {
        text-align: right;
      }
      .cent {
        position: relative;
        background: rgb(243, 242, 242);
        top: 50px;
        height: 250px;
        left: 50%;
        width: 500px;
        margin-left: -250px;
      }
      .cent h1 {
        border-bottom: 1px solid rgb(214, 212, 212);
        padding: 10px 0;
        margin: 10px 0;
        text-align: center;
      }
      .cent .line {
        height: 50px;
        line-height: 50px;
        padding: 0 40px;
      }
      .cent .line label {
        width: 80px;
        display: inline-block;
      }
      .cent .line .input {
        width: 300px;
        height: 25px;
      }
      .cent .line .submit {
        width: 70px;
        height: 30px;
        margin-right: 30px;
      }
    </style>
    <script src="/html/js/jquery.min.js"></script>
    <script>
      $(function(){
        $('#submit').click(function(){
          $.ajax({
            type: "POST",
            url: "/lua/user/login",
            data: {
              login_name:$("#login_name").val(),
              login_pwd:$("#login_pwd").val()
            },
            dataType: "json",
            success: function(data){
              if(data.data) {
                location.href = '/html/index.html';
              }else {
                alert('username or password error !')
              }
            }
          });
        });
      });
    </script>
  </head>
  <body>
    <div class="cent">
        <h1>hello, openresty !</h1>
        <div class="line">
          <label for="login_name">username</label>
          <input id="login_name" class="input" name="login_name">
        </div>
        <div class="line">
          <label for="login_pwd">password</label>
          <input id="login_pwd" class="input" type="password" name="login_pwd">
        </div>
        <div class="line right">
          <input id="submit" class="submit" type="button" value="submit">
        </div>
    </div>
  </body>
</html>
